<?
 
function sqlEscape($sql) { 
    $fix_str        = stripslashes($sql); 
    $fix_str    = str_replace("'","''",$sql); 
    $fix_str     = str_replace("\0","[NULL]",$fix_str); 
    return $fix_str; 
} 


$objConnect = mysql_connect("localhost","centralbro_user","showidea159") or die("Error Connect to Database"); // Conect to MySQL
$objDB = mysql_select_db("centralbro_db");
mysql_query("SET NAMES UTF8");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
require_once 'Classes/PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load("3no.xls");
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
                $worksheetTitle     = $worksheet->getTitle();
                $highestRow         = $worksheet->getHighestRow(); // e.g. 10
                $highestColumn      = $worksheet->getHighestColumn(); // e.g 'F'
                $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
                $nrColumns = ord($highestColumn) - 64;
				?>
                	<table width="100%" border="1" cellspacing="0" cellpadding="5">
                    <tr>
    <td width="100">B</td>
    <td>H</td>
    <td>I</td>
    <td>J</td>
    <td>K</td>
    <td>L</td>
    <td>M</td>
    <td>N</td>
    <td>O</td>
    <td>Q</td>
    <td>R</td>
    <td>S</td>
    <td>T</td>
    <td>U</td>
    <td>V</td>
    <td>W</td>
    <td>ประเภทรถ</td>
  </tr>
                    <?
                for ($row = 11; $row <= $highestRow; ++ $row) {
				
                        $cell = $worksheet->getCellByColumnAndRow(1, $row);
                        $value = $cell->getValue();
						
						$cell2 = $worksheet->getCellByColumnAndRow(7, $row);
                        $value2 = $cell2->getValue();
						
						$cell3 = $worksheet->getCellByColumnAndRow(8, $row);
                        $value3 = $cell3->getValue();
						
						$cell4 = $worksheet->getCellByColumnAndRow(9, $row);
                        $value4 = $cell4->getValue();
						
						$cell5 = $worksheet->getCellByColumnAndRow(10, $row);
                        $value5 = $cell5->getValue();
						
						$cell6 = $worksheet->getCellByColumnAndRow(11, $row);
                        $value6= $cell6->getValue();
						
						$cell7 = $worksheet->getCellByColumnAndRow(12, $row);
                        $value7 = $cell7->getValue();
						
						$cell8 = $worksheet->getCellByColumnAndRow(13, $row);
                        $value8 = $cell8->getValue();
						
						$cell9 = $worksheet->getCellByColumnAndRow(14, $row);
                        $value9 = $cell9->getValue();
						
						$cell10 = $worksheet->getCellByColumnAndRow(16, $row);
                        $value10 = $cell10->getValue();
						
						$cell11 = $worksheet->getCellByColumnAndRow(17, $row);
                   	    $value11 = $cell11->getValue();
						
						$cell12 = $worksheet->getCellByColumnAndRow(18, $row);
                   	    $value12 = $cell12->getValue();
						
						$cell13 = $worksheet->getCellByColumnAndRow(19, $row);
                   	    $value13 = $cell13->getValue();
						
						$cell14 = $worksheet->getCellByColumnAndRow(20, $row);
                   	    $value14 = $cell14->getValue();
						
						$cell15 = $worksheet->getCellByColumnAndRow(21, $row);
                   	    $value15 = $cell15->getValue();
						
						$cell16 = $worksheet->getCellByColumnAndRow(22, $row);
                   	    $value16 = $cell16->getValue();
						
						
	$strSQL = "INSERT INTO tb_3 ";
	$strSQL .="(b,h,i,j,k,l,m,n,o,q,r,s,t,u,v,w,x) ";
	$strSQL .="VALUES ";
	$strSQL .="('".$value."',
			  '".$value2."',
			  '".$value3."',
			  '".$value4."',
			  '".$value5."',
			  '".$value6."',
			  '".$value7."',
			  '".$value8."',
			  '".$value9."',
			  '".$value10."',
			  '".$value11."',
			  '".$value12."',
			  '".$value13."',
			  '".$value14."',
			  '".$value15."',
			  '".$value16."',
			  '".$worksheetTitle."'
			  )";
	$objQuery = mysql_query($strSQL) or die("error:".$strSQL."".mysql_error()."") ;
						?>
					
  <tr>
    <td width="100"><?=$value?></td>
    <td><?=$value2?></td>
    <td><?=$value3?></td>
    <td><?=$value4?></td>
    <td><?=$value5?></td>
    <td><?=$value6?></td>
    <td><?=$value7?></td>
    <td><?=$value8?></td>
    <td><?=$value9?></td>
    <td><?=$value10?></td>
    <td><?=$value11?></td>
    <td><?=$value12?></td>
    <td><?=$value13?></td>
    <td><?=$value14?></td>
    <td><?=$value15?></td>
    <td><?=$value16?></td>
    <td width="100"><?=$worksheetTitle?></td>
  </tr>

<?

                }
				?></table>
<?
}
?>
</body>

</html>